<script setup>
import { ref } from 'vue'

const isExpanded = ref(true)

// 监测点数据
const monitorPoints = ref([
  { id: 1, name: '测点1', value: '95320', status: 'normal' },
  { id: 2, name: '测点2', value: '95320', status: 'normal' },
  { id: 3, name: '测点3', value: '95320', status: 'warning' }
])

const togglePanel = () => {
  isExpanded.value = !isExpanded.value
}
</script>

<template>
  <div class="right-panel" :class="{ 'collapsed': !isExpanded }">
    <div class="toggle-btn" @click="togglePanel">
      <span class="arrow" :class="{ 'reversed': !isExpanded }">‹</span>
    </div>
    <div class="panel-content" :class="{ 'hidden': !isExpanded }">
      <div class="monitor-list">
        <h3>测点列表</h3>
        <div class="monitor-item" v-for="point in monitorPoints" :key="point.id">
          <span class="point-name">{{ point.name }}</span>
          <span class="point-value">{{ point.value }}</span>
          <span class="point-status" :class="point.status">{{ point.status }}</span>
        </div>
      </div>
    </div>
  </div>
</template>

<style lang="scss" scoped>
@use '@/assets/styles/variables' as *;

.right-panel {
  position: relative;
  width: calc($sidebar-width * var(--scale-ratio));
  height: 96%;
  background-color: $bg-panel;
  padding: calc($padding-sm * var(--scale-ratio));
  border-radius: $border-radius;
  transition: all 0.3s ease;
  overflow: visible;

  &.collapsed {
    width: 24px !important;
    padding: 0;
    overflow: visible;
    transform: translateX(100%);
  }

  .toggle-btn {
    position: absolute;
    left: -20px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 40px;
    background-color: $bg-panel;
    border-radius: 4px 0 0 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;

    .arrow {
      color: $text-color;
      font-size: 20px;
      transition: transform 0.3s ease;

      &.reversed {
        transform: rotate(180deg);
      }
    }
  }

  .panel-content {
    opacity: 1;
    transition: opacity 0.3s ease;

    &.hidden {
      opacity: 0;
    }
  }

  .monitor-list {
    h3 {
      margin-bottom: $padding-sm;
      font-size: $font-size-xl;
    }

    .monitor-item {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: $padding-xs;
      border-bottom: 1px solid $border-color;

      .point-status {
        &.normal {
          color: $success-color;
        }

        &.warning {
          color: $warning-color;
        }

        &.error {
          color: $error-color;
        }
      }
    }
  }
}
</style>
